home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d1
/
marxmenu.arc
/
ENV.MNU
< prev
next >
Wrap
Text File
|
1991-03-27
|
6KB
|
288 lines
Comment
=============================================================
Environment Editor * Copyright 1990 by Marc Perkel
This is a MarxMenu demo program that lets you edit your master
environment area. To use type: MARXMENU ENV
=============================================================
EndComment
Var
Env, Env2, Paths, Paths2, NewPath, SetString, SetA, SetB, Middle
PathLevel
Const MyEditor = 'ME.EXE'
ClearScreenOnExit Off
MasterEnvironment
ReadEnvironment(Env)
UseArrows
BoxBorderColor Green Blue
BoxInsideColor Yellow Blue
if ColorScreen
BoxHeaderColor Yellow Mag
InverseColor Yellow Red
else
BoxHeaderColor Black Grey
InverseColor Black Grey
endif
BoxHeader ' Environment '
DrawBox 27 6 32 9
TextColor LCyan Blue
ClearLine 205
TextColor Yellow Blue
Writeln
Writeln ' A - Change One Line'
Writeln ' B - Delete Lines'
Writeln ' C - Edit Environment'
Writeln ' D - Sort Environment'
Writeln ' E - Edit Paths'
Write ' F - Information'
OnKey 'A'
^SetALine
OnKey 'B'
^DelLines
OnKey 'C'
^EdEnv
OnKey 'D'
|DrawBox 33 13 11 3
|Write ' Sorting'
|Sort(1,NumberOfElements(Env))
|WasteEnv(Env)
|WriteEnv(Env)
|Wait 20
|EraseTopWindow
OnKey 'E'
^EdPath
OnKey 'F'
|BoxHeader ' Information '
|DrawBox 30 9 32 6
|TextColor LCyan Blue
|ClearLine 205
|TextColor Yellow Blue
|Writeln
|Writeln ' Environment Size: ' EnvSize
|Writeln ' Environment Free: ' EnvFree
|Write ' Environment Used: ' (EnvSize - EnvFree)
|WaitOrKBDReady 4000
|EraseTopWindow
:SetALine
if NumberOfElements(Env) > 1
BoxHeader ' Pick String to Edit '
DrawPickBox(Env)
SetString = PickOne Env
EraseTopWindow
EraseTopWindow
endif
if NumberOfElements(Env) = 1 then SetString = Env[1]
if LastKey = Esc then ExitMenu
SetA = Left(SetString,pos('=',SetString) - 1)
delete(SetString,1,pos('=',SetString))
DrawBox 1 20 80 3
Write ' ' SetA '='
InputString = SetString
SetB = Readln
EraseTopWindow
if LastKey = Esc then ExitMenu
SetEnv(SetA + '=' + SetB)
ExitMenu
:DelLines
BoxHeader ' Mark Lines to Delete '
DrawPickBox(Env)
PickMany(Env,Env2)
EraseTopWindow
EraseTopWindow
WasteEnv(Env2)
ExitMenu
:EdEnv
WriteTextFile ('ENV.TMP',Env)
Explode Off
Execute (MyEditor + ' ENV.TMP')
ReadTextFile ('ENV.TMP',Env2)
DelFile ('ENV.TMP')
DelFile ('ENV.BAK')
WasteEnv(Env)
WriteEnv(Env2)
ExitMenu
:EdPath
SeparatePaths
BoxHeader ' Edit Path '
DrawBox 30 9 32 5
TextColor LCyan Blue
ClearLine 205
TextColor Yellow Blue
Writeln
Writeln ' A - Add a Path'
Write ' B - Delete Paths'
OnKey 'A'
|DrawBox 1 20 80 3
|repeat
| Write ' New Path: '
| NewPath = UpperCase(Readln)
|until ExistDir(NewPath) or (LastKey = Esc) or (SetB = '')
|EraseTopWindow
|if ExistDir(NewPath) and (LastKey <> Esc)
| Paths[NumberOfElements(Paths) + 1] = NewPath
|endif
|MergePaths
OnKey 'B'
^DelPaths
:DelPaths
BoxHeader ' Mark Paths to Delete '
PathLevel = True
DrawPickBox(Paths)
PathLevel = False
PickMany(Paths,Paths2)
EraseTopWindow
EraseTopWindow
EraseTopWindow
EraseTopWindow
SubtractPaths(Paths,Paths2)
MergePaths
ExitMenu
;------ Recursive Quicksort
Procedure Sort (L,R)
var I,J
I = L
J = R
Middle = Env[(L+R)/2]
repeat
while Env[I] < Middle
I = I + 1
endwhile
while Middle < Env[J]
J = J - 1
endwhile
if I <= J
Middle = Env[J]
Env[J] = Env[I]
Env[I] = Middle
I = I + 1
J = J - 1
endif
until I > J
if (J - L) < (R - I)
if L < J then Sort(L,J);
if I < R then Sort(I,R);
else
if I < R then Sort(I,R);
if L < J then Sort(L,J);
endif
EndProc
Procedure WasteEnv (EnvArray)
Loop NumberOfElements(EnvArray)
EnvArray[LoopIndex] = Left(EnvArray[LoopIndex],pos('=',EnvArray[LoopIndex]))
SetEnv(EnvArray[LoopIndex])
EndLoop
EndProc
Procedure WriteEnv (EnvArray)
Loop NumberOfElements(EnvArray)
SetEnv(EnvArray[LoopIndex])
EndLoop
EndProc
Procedure DrawPickBox (ChooseList)
var BoxDim Longest
Longest = length(BoxHeader) - 2
Loop NumberOfElements(ChooseList)
Longest = Max(Longest,length(ChooseList[LoopIndex]))
EndLoop
BoxDim[3] = Min(Longest + 6,ScreenWidth - 6)
BoxDim[4] = Min(NumberOfElements(ChooseList) + 3,ScreenHeight)
if PathLevel
BoxDim[1] = Max(Min(33,ScreenWidth - BoxDim[3]),1)
BoxDim[2] = Max(Min(12,ScreenHeight - BoxDim[4]),1)
else
BoxDim[1] = Max(Min(30,ScreenWidth - BoxDim[3]),1)
BoxDim[2] = Max(Min(9,ScreenHeight - BoxDim[4]),1)
endif
DrawBox BoxDim[1] BoxDim[2] BoxDim[3] BoxDim[4]
TextColor LCyan Blue
ClearLine 205
TextColor Yellow Blue
NoBoxBorder
Explode Off
DrawBox BoxDim[1] + 1 BoxDim[2] + 2 BoxDim[3] - 2 BoxDim[4] - 3
BlockBox
Explode
EndProc
Procedure AppendPaths (Directory)
if ExistDir(Directory)
Paths[NumberOfElements(Paths) + 1] = Directory
endif
EndProc
Procedure SeparatePaths
var Path B
Path = UpperCase(ReadEnv('PATH'))
Dispose(Paths)
while Path > ''
B = pos(';',Path)
if B > 0
AppendPaths(Left(Path,B - 1))
delete(Path,1,B)
else
AppendPaths(Path)
Return
endif
endwhile
EndProc
Procedure MergePaths
var Path
Path = ''
Loop NumberOfElements(Paths)
Path = Path + Paths[LoopIndex] + ';'
EndLoop
SetEnv('PATH=' + Path)
EndProc
Procedure SubtractPaths (Org,Sub)
var I Match
Dispose(Paths)
I = 1
while I <= NumberOfElements(Org)
Match = False
Loop NumberOfElements(Sub)
if Org[I] = Sub[LoopIndex]
Match = True
endif
EndLoop
if not Match then Paths[NumberOfElements(Paths) + 1] = Org[I]
I = I + 1
endwhile
EndProc
;loop numberofelements(Paths)
; writeln Paths[loopindex]
;endloop